package com.demo.tankGame2;

/**
 * 自己的坦克 英雄
 *
 * @author gy
 * @date 2022/4/18
 */
public class Hero extends Tank {

    Shot shot = null;

    public Hero(int x, int y) {
        super(x, y);
    }

    public Hero(int x, int y, int speed) {
        super(x, y, speed);
    }

    public void shotEnemyTank() {
        // 创建 shot 对象，根据当前 Hero位置方向来创建 shot
        switch (getDirect()) {
            case 0:
                shot = new Shot(getX() + 20, getY(), 0);
                break;
            case 1:
                shot = new Shot(getX() + 60, getY() + 20, 1);
                break;
            case 2:
                shot = new Shot(getX() + 20, getY() + 60, 2);
                break;
            case 3:
                shot = new Shot(getX(), getY() + 20, 3);
                break;
            default:
        }
        // 启动我们的shot 线程
        Thread bulletThread = new Thread(shot);
        bulletThread.setName("子弹");
        bulletThread.start();
    }
}
